@echo off 
chcp 65001
if not "%OS%"=="Windows_NT" exit
title WindosActive

setlocal enabledelayedexpansion  
setlocal EnableExtensions
set "folderPath=%~dp0"  
  
@REM 获取上级路径  
set "parentPath=%folderPath%"  
for %%I in ("%folderPath%\.") do set "parentPath=%%~dpIsurvival_backend"  
  
echo now backendPath: %parentPath%  
  
if exist "%parentPath%" (  
    echo 进入后端项目 survival_backend
    cd %parentPath% 
    
    echo 正在拉取代码..
    set result = ""
    @REM 拉取代码     
    for /f "delims=" %%a in ('git pull') do set "result=%%a" 
    @REM for /f "delims=" %%a in ('git pull') do (  
    @REM     echo %%a  
    @REM     set result=%%a
    @REM     :: 检查输出行是否包含冲突信息  
    @REM )  
    echo %result% 
    @REM 检查是否有冲突  
    @REM if exist ".git\MERGE_MSG" (  
    @REM     echo 拉取代码冲突发生，请手动解决冲突。  
    @REM     pause  
    @REM     exit /b 1  
    @REM )  
    @REM echo after  %cd%
    npm run apidoc
    echo apidoc 编译成功 
    
    echo 正在生成xyc..
    echo to: %~dp0
    cd /D %~dp0
    cd tool
    echo %cd%
    @REM echo %0
    @REM echo after  %cd%
    ts-node index.ts --export 
    pause

) else (  
    @REM echo before  %cd%
    echo to: %~dp0
    cd /D %~dp0
    @REM echo %0
    echo %cd%
    @REM echo after  %cd%
    ts-node tool\index.ts --export 
    pause
)  

